import os
import execjs


class Mock(object):
    def __init__(self):
        os.environ["NODE_PATH"] = os.getcwd() + "/node_modules"
        self.context = execjs.compile("""
                var Mock = require('mockjs');
                function mock(expression) {
                    return Mock.mock(expression);
                }
            """)

    def mock(self, expression):
        return self.context.call("mock", expression)
Mock = Mock()
